//// Copyright 2013, Egor Dolzhenko
////
//// This file is part of rearrangement-toolkit.
////
//// Rearrangement-toolkit is free software: you can redistribute it and/or modify
//// it under the terms of the GNU General Public License as published by
//// the Free Software Foundation, either version 3 of the License, or
//// (at your option) any later version.

//// Rearrangement-toolkit is distributed in the hope that it will be useful,
//// but WITHOUT ANY WARRANTY; without even the implied warranty of
//// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//// GNU General Public License for more details.
////
//// You should have received a copy of the GNU General Public License
//// along with Rearrangement-toolkit.  If not, see <http://www.gnu.org/licenses/>.

//// Contents:
//// (1) a type Strings which is a vetor of strings,
//// (2) a type Segments which is a vector of segments,
//// (3) a struct SegmentPair containing info about a pair of similar segments,
//// (4) a class SegmentPairLibrary which is used to process BLAST output from a
////     file on a disk.

//#include <iostream>
//#include <fstream>
//#include <sstream>
//#include "segment_pair_library.h"

//using namespace std;

//SegmentPairLibrary::SegmentPairLibrary(string filename)
//  :blast_file_(filename) {
//  if(!blast_file_.is_open()) {
//    cerr << "unable to open " << filename << endl;
//    return;
//  }
//  parseNextSegmentPair();
//}

//Strings SegmentPairLibrary::tabSplit(string line) {
//  istringstream iss(line);
//  string token;
//  Strings tokens;
//  while(getline(iss, token, '\t'))
//    tokens.push_back(token);
//  return tokens;
//}

//bool SegmentPairLibrary::parseNextSegmentPair() {
//  string line;
//  getline(blast_file_, line);
//  if(line.empty()) return false;
//  Strings tokens = tabSplit(line);
//  current_segment_pair_.product_name = tokens[0];
//  current_segment_pair_.precursor_name = tokens[1];
//  current_segment_pair_.length = stoi(tokens[3]);
//  int precursor_first = stoi(tokens[8]);
//  int precursor_second = stoi(tokens[9]);
//  int product_first = stoi(tokens[6]);
//  int product_second =  stoi(tokens[7]);
//  bool is_reversed = (precursor_first > precursor_second) || (product_first > product_second);
//  current_segment_pair_.product_start = min(product_first, product_second);
//  current_segment_pair_.product_end = max(product_first, product_second);
//  current_segment_pair_.precursor_start = min(precursor_first, precursor_second);
//  current_segment_pair_.precursor_end = max(precursor_first, precursor_second);
//  current_segment_pair_.is_reversed = is_reversed;
//  return true;
//}

//bool SegmentPairLibrary::next() {
//  cur_precursor_name_ = current_segment_pair_.precursor_name;
//  cur_product_name_ = current_segment_pair_.product_name;
//  segment_pairs_.clear();
//  while (cur_precursor_name_.compare(current_segment_pair_.product_name) == 0 &&
//         cur_product_name_.compare(current_segment_pair_.product_name) == 0) {
//    segment_pairs_.push_back(current_segment_pair_);
//    if (!parseNextSegmentPair()) return false;
//  }
  
//  return true;
//}
